package com.waypolice.manager.service.impl;

import com.waypolice.base.BaseServiceImpl;
import com.waypolice.manager.service.UpmsDictionaryService;
import com.waypolice.mapper.UpmsDictionaryMapper;
import com.waypolice.pojo.UpmsDictionary;
import com.waypolice.pojo.UpmsDictionaryExample;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
* UpmsDictionaryService实现
* Created by lzh on 2019/3/12.
*/
@Service
public class UpmsDictionaryServiceImpl extends BaseServiceImpl<UpmsDictionaryMapper, UpmsDictionary, UpmsDictionaryExample> implements UpmsDictionaryService {

    private static final Logger LOGGER = LoggerFactory.getLogger(UpmsDictionaryServiceImpl.class);

    @Autowired
    private UpmsDictionaryMapper upmsDictionaryMapper;

    /**
     * @author:zyp
     * @description 根据父code 获取下级应用的字典code
     * @date: 2019/3/19 17:41
     * @return
     */
    @Override
    public List<UpmsDictionary> getUpmsDictionaryByCode(String parentCode) {
        UpmsDictionaryExample upmsDictionaryExample = new UpmsDictionaryExample();
        UpmsDictionaryExample.Criteria criteria = upmsDictionaryExample.createCriteria();
        criteria.andFatherCodeEqualTo(parentCode);
        List<UpmsDictionary> upmsDictionaries = upmsDictionaryMapper.selectByExample(upmsDictionaryExample);
        return upmsDictionaries;
    }

    @Override
    public List<UpmsDictionary> findAllStorageTime() {
        UpmsDictionaryExample upmsDictionaryExample = new UpmsDictionaryExample();
        UpmsDictionaryExample.Criteria criteria = upmsDictionaryExample.createCriteria();
        criteria.andFatherCodeEqualTo("preservationDate");
        List<UpmsDictionary> upmsDictionaries = upmsDictionaryMapper.selectByExample(upmsDictionaryExample);
        return upmsDictionaries;
    }

    @Override
    public List<UpmsDictionary> findAllSecretLevel() {
        UpmsDictionaryExample upmsDictionaryExample = new UpmsDictionaryExample();
        UpmsDictionaryExample.Criteria criteria = upmsDictionaryExample.createCriteria();
        criteria.andFatherCodeEqualTo("mg");
        List<UpmsDictionary> upmsSecretLevel = upmsDictionaryMapper.selectByExample(upmsDictionaryExample);
        return upmsSecretLevel;
    }

    @Override
    public List<UpmsDictionary> findStorageTimeTypeByCode(String volClass) {
        UpmsDictionaryExample example = new UpmsDictionaryExample();
        UpmsDictionaryExample.Criteria criteria = example.createCriteria();
        criteria.andCodeEqualTo(volClass);
        List<UpmsDictionary> types = upmsDictionaryMapper.selectByExample(example);
        return types;
    }

    @Override
    public List<UpmsDictionary> findAllSearchScope() {
        UpmsDictionaryExample upmsDictionaryExample = new UpmsDictionaryExample();
        UpmsDictionaryExample.Criteria criteria = upmsDictionaryExample.createCriteria();
        criteria.andFatherCodeEqualTo("Search");
        List<UpmsDictionary> upmsDictionaries = upmsDictionaryMapper.selectByExample(upmsDictionaryExample);
        return upmsDictionaries;
    }
}